package fr.upstlse.glre.client.widgets.fields;

import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;

import fr.upstlse.glre.client.constante.fields.LibelleConstante;
import fr.upstlse.glre.client.vo.depot.LibelleVOGWT;


public class LibelleFields implements IFields {
	FormPanel formPanel;
	LibelleVOGWT libelleVOGWT;
	
	TextField<String> id;
	TextField<String> intitule;
	
	public LibelleFields(LibelleVOGWT pLibelleVOGWT, FormPanel pFormPanel) {
		libelleVOGWT = pLibelleVOGWT;
		formPanel = pFormPanel;
		
		id = new TextField<String>();
		intitule = new TextField<String>();
		
		createFields();
		
		if(libelleVOGWT != null) {
			setFieldsValues();
		}
	}
	
	public void createFields() {
		id.setName(LibelleConstante.ID.getValue());
		id.setVisible(false);
		id.setLabelStyle("display: none");
		formPanel.add(id);
		
		intitule.setName(LibelleConstante.INTITULE_NAME.getValue());
		intitule.setFieldLabel(LibelleConstante.INTITULE_LABEL.getValue());
		formPanel.add(intitule);

	}

	public void removeFields() {
		formPanel.remove(id);
		formPanel.remove(intitule);

	}

	public void setFieldsValues() {
		id.setValue(new Long(libelleVOGWT.getId()).toString());
		intitule.setValue(libelleVOGWT.getIntitule());
	}

	public FormPanel getFormPanel() {
		return formPanel;
	}

	public void setFormPanel(FormPanel formPanel) {
		this.formPanel = formPanel;
	}

	public LibelleVOGWT getLibelleVOGWT() {
		return libelleVOGWT;
	}

	public void setLibelleVOGWT(LibelleVOGWT libelleVOGWT) {
		this.libelleVOGWT = libelleVOGWT;
	}

	public TextField<String> getId() {
		return id;
	}

	public void setId(TextField<String> id) {
		this.id = id;
	}

	public TextField<String> getIntitule() {
		return intitule;
	}

	public void setIntitule(TextField<String> intitule) {
		this.intitule = intitule;
	}
}
